import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        int gameValue = (int) (Math.random() * 100);
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入一个整数(0-100)");
        while (!sc.hasNextInt()){

            System.out.println("你输入的不是(0-100)的正整数");

            System.out.println("请重新输入：");

            sc.next();

        }

        int guessCorrectNum = 0; //初始化猜测次数

        while (true) {

            int num = sc.nextInt();

            guessCorrectNum++;
            if (num > gameValue) {

                System.out.println("您猜的数大了,次数：" + guessCorrectNum );

                System.out.println("请继续输入！");

            } else if (num < gameValue) {

                System.out.println("您猜的数小了,次数" + guessCorrectNum);

                System.out.println("请继续输入！");

            } else if (num == gameValue) {

                if (guessCorrectNum == 1)

                    System.out.println("你太有才了! \n答案是：" + gameValue);

                else if ((guessCorrectNum >= 4) && (guessCorrectNum <= 6))

                    System.out.println("这么快就猜出来了，很聪明么！ \n答案是：" + gameValue);

                else if ((guessCorrectNum >= 7) && (guessCorrectNum <20))

                    System.out.println("猜了半天才猜出来，小同志，尚需努力啊！ \n答案是：" + gameValue);

                break;

            }
            if (guessCorrectNum >=7) {

                System.out.println("7次都猜不出来...,不让你猜了\n答案是："+ gameValue);

                break;

            }
        }
    }
}
